<?php

/*
 * 接口：/salary/search
 * 说明：查询工资（创建用）
 */

//获取请求参数
$params = $route -> restfulParams;

//拼接年份筛选条件
$yearStr = " AND b.osr_year = " . $params['osr_year'];

//拼接月份筛选条件
$monthStr = " AND b.osr_month = " . $params['osr_month'];

//拼接当前用户筛选条件
$userStr = " AND u_id = " . $params['u_id'];

//年月筛选参
$and = "";
if ($params['osr_year'] && $params['osr_month']) {
	$and = $yearStr . $monthStr;
} else {
	if ($params['osr_year']) {
		$and = $and . $yearStr;
	}
	if ($params['osr_month']) {
		$and = $and . $monthStr;
	}
}

//当前用户筛选参
$end = "";
if ($params['u_id']) {
	$end = $userStr;
}

//要执行的SQL语句
$sql = "SELECT a.u_id,a.u_username,a.u_nickname,a.u_phone,b.* FROM sys_user AS a LEFT JOIN easyd_oa_salary_record AS b ON a.u_id = b.osr_uid " . $and . " WHERE u_is_delete = 0" . $end;

//执行该SQL语句后，返回结果
$result = $db -> mysqlDB -> query($sql);

//我们将结果返回出来
$response -> responseData(true, $result);
?>